#pragma once
#include "StdAfx.h"
#include "PathFlow.h"


PathFlow::PathFlow()
{
	this -> path = list<string>();
	this -> flow = 0;
}


PathFlow::PathFlow(list<string> path, int flow)
{
	this -> path = path;
	this -> flow = flow;
}

string PathFlow::toString(){
	list<string>::iterator it;	
	string out ="";
	for ( it = path.begin(); it != path.end(); it++){
		if ( it != path.begin() ){
			out += " ";
		}
		out += (*it);
	}

	return out;
}

PathFlow::~PathFlow(void)
{
}


/* return number of edges */
int PathFlow::getLength(){
	if ( path.size() == 0 || path.size() == 1){
		return 0;
	} else{
		return path.size();
	}


}


int PathFlow::getLengthTo(string v){
	list<string>::iterator it;
	int position = 1;
	for ( it = path.begin(); it != path.end(); it++){
		if ( (*it) == v){
			return position-1;
		}
		position++;
	}
	return -1;
}

int PathFlow::getLengthFrom(string v){
	list<string>::iterator it;
	int position = 1;
	for ( it = path.begin(); it != path.end(); it++){
		if ( (*it) == v){
			return path.size()-position;
		}
		position++;
	}
	return -1;
}
